package com.ase.javabase.KMP;

import java.util.Arrays;

/**
 * @author gyhstart
 * @create 2021/3/8 - 20:48
 **/
public class copy {
    public static void main(String[] args) {

        /**
         * Java如何进行高效的数组拷贝
         */
        int[] arr = {1, 2, 3, 4, 5, 6, 7, 8, 9};
        int[] arr2 = Arrays.copyOf(arr ,5);
        int[] arr3 = new int[6];
        System.arraycopy(arr, 2, arr3,0,6);
        System.out.println("arr2 = " + Arrays.toString(arr2));
        System.out.println("arr3 = " + Arrays.toString(arr3));
    }
}
